package io;

import java.io.*;

/**
 *使用缓冲流完成文件的复制操作
 *
 * 缓冲流:
 * Java.io.BufferedInputStream和BufferedOutputStream
 * 缓冲流是一对高级流,在连接中的作用是提高读写字节数据的效率
 */
public class CopyDemo3 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("D:/Users/King/Downloads/Video/长剑风云/长剑风云1.fly");
        BufferedInputStream bis = new BufferedInputStream(fis);
        FileOutputStream fos = new FileOutputStream("D:/Users/King/Downloads/Video/长剑风云/长剑风云1-1.fly");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        int d;
        long start = System.currentTimeMillis();
        while ((d=bis.read())!=-1){
            bos.write(d);
        }

        long end = System.currentTimeMillis();
        System.out.println("复制完成:"+(end-start)+"ms");
        System.out.println();
        bis.close();
        bos.close();
    }
}
